package com.douyang.base.model;

import lombok.Data;

import java.io.Serial;
import java.io.Serializable;

@Data
public class Result<T> implements Serializable {
    @Serial
    private static final long serialVersionUID = -415877140189946393L;

    private int code;

    private T data;

    private String msg;

    public Result(int code, T data, String msg) {
        this.code = code;
        this.data = data;
        this.msg = msg;
    }

    public static <T> Result<T> success(T data) {
        Result<T> result=new Result<T>();
        result.setCode(200);
        result.setData(data);
        result.setMsg("success");
        return result;
    }
    public static <T> Result<T> fail(String msg) {
        Result<T> result=new Result<T>();
        result.setCode(500);
        result.setMsg(msg);
        return result;
    }

    public Result() {
    }
}
